/**
 * Created by xlt on 2017/5/8.
 */
import React from "react";
import cookie from "react-cookie";
import {connect} from "react-redux";
import {fetchPosts, reset} from "../../actions";

class scanCode extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            invalidReq : false
        }
    }

    componentWillMount() {
        document.title = "叮叮收钱";
    }

    componentDidMount() {
        const query = this.props.location.query;
        var ua = window.navigator.userAgent.toLowerCase();
        // var ua = "mozilla/5.0 (linux; android 6.0; nem-al10 build/honornem-al10; wv) applewebkit/537.36 (khtml, like gecko) version/4.0 chrome/53.0.2785.49 mobile mqqbrowser/6.2 tbs/043220 safari/537.36 micromessenger/6.5.8.1060 nettype/4g language/zh_cn";
        if (ua.match(/MicroMessenger/i) == 'micromessenger' ) {
            window.location.href = "http://weixin.hzyisu.com/wechat/authenticationInfo?callBackPageType=PAY_MAIN_SCAN&mch_id=" + query.shopNo;
        } else if (ua.match(/AlipayClient/i) == 'alipayclient') {
            window.location.href = "http://weixin.hzyisu.com/aliPay/authentication?shopNo=" + query.shopNo;
        } else {
            this.setState({
                invalidReq: true
            })
        }
    }

    render() {
        if(this.state.invalidReq) {
            return (
                <div>
                    <img src="http://oeb6w1s1c.bkt.clouddn.com/disable_pay.jpg" style={{width: '100%', height: '100%'}}/>
                </div>
            )
        } else {
            return(
                <div></div>
            )
        }
    }
}

export default scanCode;